import ash from '@ash.ts/ash';
import { _decorator, Component, Label, Node } from 'cc';
const { ccclass, property } = _decorator;


@ccclass('WaitForStartView')
export class WaitForStartView extends Component {
    @property(Label)
    gameOver: Label;

    public click: ash.Signal0 = new ash.Signal0();

    protected onLoad(): void {
        this.node.on(Node.EventType.MOUSE_UP, this.dispatchClick, this);
        this.node.on('addedToStage', this.addClickListener, this);
        this.node.on('removedFromStage', this.removeClickListener, this);
    }
    private removeClickListener() {
        this.node.off(Node.EventType.MOUSE_UP, this.dispatchClick, this);
        this.gameOver.string = 'Game Over';
    }

    private addClickListener() {
        this.node.on(Node.EventType.MOUSE_UP, this.dispatchClick, this);
    }

    private dispatchClick() {
        this.click.dispatch();
    };

}
